<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
import { createSocket, disConnect } from '@/hooks/socket';
onLaunch(() => {
  console.log('App Launch');
});
onShow(() => {
  console.log('App Show');
  let pages = getCurrentPages();
  let currentPage = pages[pages.length - 1]; // 当前页面
  if (
    uni.getStorageSync('Token') &&
    currentPage &&
    currentPage.route !== 'pages/login/index'
  ) {
    createSocket();
  }
});
onHide(() => {
  console.log('App Hide');
  disConnect();
});
</script>
<style lang="scss">
@import './static/iconfont.css';
@import './uni_modules/vk-uview-ui/index.scss';
page {
  background: #f0f1f2;
  // background: #000;
}

.font-bold {
  font-weight: bold;
}

.primary {
  color: $u-type-primary;
}
.warning {
  color: $u-type-warning;
}
.success {
  color: $u-type-success;
}
.error {
  color: $u-type-error;
}
.info {
  color: $u-type-info;
}

.status-bar {
  height: 32px;
  width: 100%;
  text-align: center;
  color: #fff;
  font-weight: 400;
  font-size: 16px;
  line-height: 32px;
  position: relative;
  z-index: 2;

  u-icon {
    position: absolute;
    left: 5%;
  }
}
</style>
